***************************************************************************
*** Yujeong Yang, Sanghoon Kim-Leffingwell, Shuyuan Shen, Do Young Gong	***
*** Kill Protests with Kindness											***		
****Anti-China Protests and China's Public Diplomacy					***
*** May, 2023															***
***************************************************************************
use "KillProtests.dta", clear

xtset cowcode year
****************************************************************
*Table 1 : Anti-China Protests and Polity on Government Visits**
*****************************************************************
eststo clear
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##c.polity2L1   i.year  , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lnpop NaturalResources  urban_pop electricity   i.year  , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lnpop NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year  , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lnpop NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita i.year  , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lnpop NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year  , fe
esttab using "tab1.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


**************************************************************
*Table 2: Anti-China Protests and Polity on Chinese Aid*******
**************************************************************
eststo clear
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln  c.protestL1##c.polity2L1   i.year  , fe  
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln  c.protestL1##c.polity2L1  lngdppc lnpop NaturalResources  urban_pop electricity   i.year  , fe 
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln  c.protestL1##c.polity2L1  lngdppc lnpop NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year  , fe 
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln  c.protestL1##c.polity2L1  lngdppc lnpop NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita i.year  , fe  
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln  c.protestL1##c.polity2L1  lngdppc lnpop NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year , fe  

esttab using "table2.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


**********************
****Figures***********
***********************

*Figure 4.
twoway line polity2   year, by(country) xlab(2000(5)2020)
 
 *Figure 5. 
qui xtnbreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lnpop NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year  , fe
qui margins, dydx(protestL1) at (polity2L1 =(-10(2)10)) force
marginsplot, yline(0)  recast(line)  plotopts(lw(medthick)) recastci(rline) ciopts(lp(dash)) addplot(histogram polity2L1,  xlab(-10(2)10) yaxis(2) fcolor(none) lcolor(grey)) level(90) graphregion(fcolor(white)) legend(off)

*Figure 6.  
qui xtreg OFa_all_pop_ln L1.OFa_all_pop_ln  c.protestL1##c.polity2L1  lngdppc lnpop NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year  , fe 
qui margins, dydx(protestL1) at (polity2L1 =(-10(2)10)) force
marginsplot, yline(0)  recast(line)  plotopts(lw(medthick)) recastci(rline) ciopts(lp(dash)) addplot(histogram polity2L1,  xlab(-10(2)10) yaxis(2) fcolor(none) lcolor(grey)) level(90) graphregion(fcolor(white)) legend(off)



****************
***APPENDICES***
****************
 
*Table A1: Summary Statistics
asdoc sum government_visits  total_elite_visits   OFa_all_pop_ln protest polity2  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover ChinaTradeOpenness chinese_ofdi_inflow_gdp    , label
 
 
*Table A2: Anti-China Protests and Polity on Government Elite Visits (No Year-fixed effects)*
eststo clear
eststo: xtnbreg government_visits L1.government_visits  c.protestL1##c.polity2L1  yeartrend  , fe
eststo: xtnbreg government_visits L1.government_visits  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity     yeartrend , fe
eststo: xtnbreg government_visits L1.government_visits  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  yeartrend  , fe
eststo: xtnbreg government_visits L1.government_visits  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita   yeartrend , fe
eststo: xtnbreg government_visits L1.government_visits  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover   yeartrend , fe
esttab using "tab_a2.rtf", label   nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


*Table A3 : Anti-China Protests and Polity on Chinese Aid (No Year-fixed effects) *
eststo clear
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.protestL1##c.polity2L1   yeartrend , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity   yeartrend  , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  yeartrend  , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita yeartrend  , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  yeartrend  , fe
esttab using "tab_a3.rtf", label   nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


*Table A4: Anti-China Protests and Polity on Total Elite Visits (Visits by Government and Military Officials)*
eststo clear
eststo: xtnbreg total_elite_visits L1.total_elite_visits  c.protestL1##c.polity2L1 i.year , fe
eststo: xtnbreg total_elite_visits L1.total_elite_visits  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity i.year   , fe
eststo: xtnbreg total_elite_visits L1.total_elite_visits  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
eststo: xtnbreg total_elite_visits L1.total_elite_visits  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita i.year   , fe
eststo: xtnbreg total_elite_visits L1.total_elite_visits  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
esttab using "tab_a4.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


*Table A5. Anti-China Protests and Polity on Government Elite Visits (with Interactions)

eststo clear
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##c.polity2L1  c.protestL1##c.lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lngdp c.protestL1##c.NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity c.protestL1##c.FDI_inflow tradeopenness  i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources c.protestL1##c.chinese_ofdi_inflow_gdp urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
esttab using "tab_a5.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


*Table A6: Anti-China Protests and Polity on Chinese Aid (with Interactions)
eststo clear 
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln  c.protestL1##c.polity2L1  c.protestL1##c.lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln  c.protestL1##c.polity2L1  lngdppc lngdp c.protestL1##c.NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity c.protestL1##c.FDI_inflow tradeopenness   i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources c.protestL1##c.chinese_ofdi_inflow_gdp urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
esttab using "tab_a6.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


*Table A7: Anti-China Protests (in log) and Polity on Elite Visits
gen lnprotest=ln(protest+1)
gen lnprotestL1=L1.lnprotest
eststo clear
eststo: xtnbreg government_visits L1.government_visits   c.lnprotestL1##c.polity2L1   i.year  , fe
eststo: xtnbreg government_visits L1.government_visits   c.lnprotestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity   i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.lnprotestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.lnprotestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.lnprotestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
esttab using "tab_a7.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))

*Table A8: Anti-China Protests (in log) and Polity on Chinese Aid
eststo clear
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.lnprotestL1##c.polity2L1   i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.lnprotestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity   i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.lnprotestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.lnprotestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.lnprotestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
esttab using "tab_a8.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))




*Table A9: OLS analysis of Anti-China Protests and Polity on Elite Visits
eststo clear
eststo: xtreg government_visits L1.government_visits   c.protestL1##c.polity2L1   i.year  , fe
eststo: xtreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity   i.year , fe
eststo: xtreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year  , fe
eststo: xtreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita i.year  , fe
eststo: xtreg government_visits L1.government_visits   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year  , fe

esttab using "tab_a9.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))

*Table A10: Anti-China Protests per capita and Polity on Government Visits
gen protestpc=protest/population
gen protestpcL1=L1.protestpc

eststo clear
eststo: xtnbreg government_visits L1.government_visits   c.protestpcL1##c.polity2L1   i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestpcL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity   i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestpcL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestpcL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestpcL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
esttab using "tab_a10.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


*Table A11: Anti-China Protests per capita and Polity on Chinese Aid
eststo clear
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.protestpcL1##c.polity2L1   i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.protestpcL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity   i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.protestpcL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.protestpcL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita i.year   , fe
eststo: xtreg OFa_all_pop_ln L1.OFa_all_pop_ln   c.protestpcL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
esttab using "tab_a11.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))

*Table A12: Anti-China Protests and Polity on Top Elite Visits
eststo clear
eststo: xtreg leader_visits  c.protestL1##c.polity2L1   i.year   , fe robust
eststo: xtreg leader_visits  L1.leader_visits c.protestL1##c.polity2L1   i.year   , fe robust
eststo: xtreg leader_visits  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity   i.year   , fe robust
eststo: xtreg leader_visits  c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe robust
esttab using "tab_a12.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


*Table A13: Anti-China Protests and Alternative Measures of Democracy
gen bipolity=1 if polity2~=. &polity2 >=6
replace bipolity=0 if polity2~=.&polity2<6
gen bipolityL1=L1.bipolity

eststo clear
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##i.bipolityL1   lngdppc lngdp NaturalResources  urban_pop electricity   FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##i.fhscoreL1   lngdppc lngdp NaturalResources  urban_pop electricity   FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
eststo: xtnbreg government_visits L1.government_visits   c.protestL1##c.v2x_polyarchy_L1  lngdppc lngdp NaturalResources  urban_pop electricity   FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
eststo: xtreg OFa_all_pop_ln  L1.OFa_all_pop_ln   c.protestL1##i.bipolityL1  lngdppc lngdp NaturalResources  urban_pop electricity   FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
eststo: xtreg OFa_all_pop_ln  L1.OFa_all_pop_ln   c.protestL1##i.fhscoreL1  lngdppc lngdp NaturalResources  urban_pop electricity   FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
eststo: xtreg OFa_all_pop_ln  L1.OFa_all_pop_ln   c.protestL1##c.v2x_polyarchy_L1  lngdppc lngdp NaturalResources  urban_pop electricity   FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
esttab using "tab_a13.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))



*Table A14: Anti-China Protests and Polity on ODA and OOF
eststo clear
eststo: xtreg OFa_oda_pop_ln L1.OFa_oda_pop_ln   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
eststo: xtreg OFa_oda_pop_ln L1.OFa_oda_pop_ln   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita i.year   , fe
eststo: xtreg OFa_oda_pop_ln L1.OFa_oda_pop_ln   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
eststo: xtreg OFa_oofv_pop_ln L1.OFa_oofv_pop_ln   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness  i.year   , fe
eststo: xtreg OFa_oofv_pop_ln L1.OFa_oofv_pop_ln   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity ChinaTradeOpenness chinese_ofdi_inflow_gdp chineseworkers_capita i.year   , fe
eststo: xtreg OFa_oofv_pop_ln L1.OFa_oofv_pop_ln   c.protestL1##c.polity2L1  lngdppc lngdp NaturalResources  urban_pop electricity FDI_inflow tradeopenness chineseworkers_capita  bri_carryover  i.year   , fe
esttab using "tab_a14.rtf", label drop(  *year* )  nonotes se(3) b(4) replace star(+ 0.10 * 0.05 ** 0.01) compress nogaps  nobase nodepvars mtitles("" "" "" "" "" "") stats(N N_g, fmt(0 0 ) label(Observations Countries ))


